<?php
/**
 * User: 五哥派
 * Date: 2024/7/1
 * Tel(同WX): 17335592719
 */
namespace app\api\controller\v1;

use app\api\controller\ApiBase;
use app\api\service\Pay as PayService;
use app\api\service\WxNotify as WxNotifyService;

class Pay extends ApiBase {

    protected $sPayService;
    protected $sWxNotifyService;


    public function __construct(PayService $sPayService, WxNotifyService $sWxNotifyService){
        parent::__construct();
        $this->sPayService = $sPayService;
        $this->sWxNotifyService = $sWxNotifyService;
    }


    //正常下单微信订单支付
    public function getPreOrder(){
        $orderId = $this->request->post('id');//订单id

        // (new IDMustBePositiveInt()) -> goCheck();
        $type = 0; //1支持分账 0不进行分账
        $signature = $this->sPayService->pay($orderId, $type);
        return success('成功', compact('signature'));
    }

    //支付回调
    public function receiveNotify(){
        $this->sWxNotifyService->handle();
    }





}